package com.empire.module.spider.controller.app.lotteryfootballmatch500wan;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.empire.framework.common.pojo.PageParam;
import com.empire.framework.common.pojo.PageResult;
import com.empire.framework.common.pojo.CommonResult;
import com.empire.framework.common.util.object.BeanUtils;
import static com.empire.framework.common.pojo.CommonResult.success;

import com.empire.framework.excel.core.util.ExcelUtils;

import com.empire.framework.apilog.core.annotation.ApiAccessLog;
import static com.empire.framework.apilog.core.enums.OperateTypeEnum.*;

import com.empire.module.spider.controller.app.lotteryfootballmatch500wan.vo.*;
import com.empire.module.spider.dal.dataobject.lotteryfootballmatch500wan.LotteryFootballMatch500wanDO;
import com.empire.module.spider.service.lotteryfootballmatch500wan.LotteryFootballMatch500wanService;

@Tag(name = "用户 APP - 足彩比赛")
@RestController
@RequestMapping("/spider/lottery-football-match500wan")
@Validated
public class AppLotteryFootballMatch500wanController {

    @Resource
    private LotteryFootballMatch500wanService lotteryFootballMatch500wanService;

    @PostMapping("/create")
    @Operation(summary = "创建足彩比赛")
    public CommonResult<String> createLotteryFootballMatch500wan(@Valid @RequestBody AppLotteryFootballMatch500wanSaveReqVO createReqVO) {
        return success(lotteryFootballMatch500wanService.createLotteryFootballMatch500wan(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新足彩比赛")
    public CommonResult<Boolean> updateLotteryFootballMatch500wan(@Valid @RequestBody AppLotteryFootballMatch500wanSaveReqVO updateReqVO) {
        lotteryFootballMatch500wanService.updateLotteryFootballMatch500wan(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除足彩比赛")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteLotteryFootballMatch500wan(@RequestParam("id") String id) {
        lotteryFootballMatch500wanService.deleteLotteryFootballMatch500wan(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得足彩比赛")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppLotteryFootballMatch500wanRespVO> getLotteryFootballMatch500wan(@RequestParam("id") String id) {
        LotteryFootballMatch500wanDO lotteryFootballMatch500wan = lotteryFootballMatch500wanService.getLotteryFootballMatch500wan(id);
        return success(BeanUtils.toBean(lotteryFootballMatch500wan, AppLotteryFootballMatch500wanRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得足彩比赛分页")
    public CommonResult<PageResult<AppLotteryFootballMatch500wanRespVO>> getLotteryFootballMatch500wanPage(@Valid AppLotteryFootballMatch500wanPageReqVO pageReqVO) {
        PageResult<LotteryFootballMatch500wanDO> pageResult = lotteryFootballMatch500wanService.getLotteryFootballMatch500wanPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppLotteryFootballMatch500wanRespVO.class));
    }

    @GetMapping("/export-excel")
    @Operation(summary = "导出足彩比赛 Excel")
    @ApiAccessLog(operateType = EXPORT)
    public void exportLotteryFootballMatch500wanExcel(@Valid AppLotteryFootballMatch500wanPageReqVO pageReqVO,
              HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<LotteryFootballMatch500wanDO> list = lotteryFootballMatch500wanService.getLotteryFootballMatch500wanPage(pageReqVO).getList();
        // 导出 Excel
        ExcelUtils.write(response, "足彩比赛.xls", "数据", AppLotteryFootballMatch500wanRespVO.class,
                        BeanUtils.toBean(list, AppLotteryFootballMatch500wanRespVO.class));
    }

}
